package com.ttl.bc.ar.reqconfirm.bean;

import org.displaytag.decorator.TableDecorator;


public class BCReqConfirmDecorator extends TableDecorator {
	
	public String getQty1() {						
		BCReqConfirmShowBean obj = (BCReqConfirmShowBean)getCurrentRowObject();
		float qty = obj.getQty();
				
		return "<label align = 'right'>"+qty+"</label>";

	}
	
	public String getIttl_status() {
		
		BCReqConfirmShowBean obj = (BCReqConfirmShowBean)getCurrentRowObject();
		
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			return "ขอซื้อ";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
			return "รอซื้อ";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("2")) {
			return "ซื้อแล้ว";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("3")) {
			return "จ่ายแล้ว";			
		}else {
			return "ยกเลิกขอซื้อ";
		}		
				
	}
	
	public String getMode() {		
		
		BCReqConfirmShowBean obj = (BCReqConfirmShowBean)getCurrentRowObject();
		String docNo = obj.getDocNo();				
		@SuppressWarnings("unused")
		int billStatus = obj.getBillStatus();		
		
		String print = "";
		String po = "";
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			po = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=create&docNo="+docNo+"\">สร้างใบ PO</a>  ";

		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) { 
			po = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=delete&docNo="+docNo+"\">ยกเลิก PO</a> | ";			
			print = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=print&docNo="+docNo+"\" target=\"_blank\">Print</a>";
			
		}else if (obj.getIttl_status()!=null && (obj.getIttl_status().equals("2")||obj.getIttl_status().equals("3")) ) {
			po = "บันทึกอินวอยซ์แล้ว ";
			
		}else {
			po = "ยกเลิกขอซื้อ";
		}
		
		return "<center>"+po+print+"</center>";						
	}
}
